import java.util.Calendar;
import java.util.Date;

import bean.User;

public class No23 {
	private static User user = new User();

	private static void initUser() {
		Calendar calendar = Calendar.getInstance();
		calendar.set(1988, 4, 2);
		calendar.set(Calendar.HOUR, 0);
		calendar.set(Calendar.MINUTE, 0);
		calendar.set(Calendar.SECOND, 0);
		calendar.set(Calendar.MILLISECOND, 0);
		user.setFirstName("Tommy");
		user.setLastName("Lee");
		user.setBirthday(calendar.getTime());
		user.setAddress("133 3rd Avenue, Plum Street 10299.");

	}

	public static void main(String[] args) {
		initUser();
		System.out.println(user);
		Calendar validAge = Calendar.getInstance();
		validAge.add(Calendar.YEAR, -20);
		validAge.set(Calendar.HOUR, 0);
		validAge.set(Calendar.MINUTE, 0);
		validAge.set(Calendar.SECOND, 0);
		validAge.set(Calendar.MILLISECOND, 0);
		
		System.out.println(validAge.getTime());

		if (user.getFirstName().length() > 50) {
			System.out.println("Invalid user firstName");
		} else if (user.getLastName().length() > 50) {
			System.out.println("Invalid user lastName");
		} else if (user.getBirthday().compareTo(validAge.getTime()) >= 0) {
			System.out.println("Invalid user birthDate");
		} else if (!user.getAddress().matches("^.*\\d{5}.*$")) {
			System.out.println("Invalid user Address");
		} else {
			System.out.println("Valid user");
		}
	}
}
